import 'package:FineArt/core/utils/toast.dart';
import 'package:FineArt/utils/size_config.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

class Background extends StatelessWidget {
  final Widget child;
  final Function tapPress;
  Background({
    Key key,
    @required this.child,
    this.tapPress
  }) : super(key: key);
  final TapGestureRecognizer _tapGestureRecognizer = new TapGestureRecognizer();
  final TapGestureRecognizer _tapGestureRecognizerPri =
      new TapGestureRecognizer();

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    _tapGestureRecognizer.onTap = () {
      ToastUtils.toast("用户协议");
    };
    _tapGestureRecognizerPri.onTap = () {
      ToastUtils.toast("隐私协议");
    };
    return Container(
      width: double.infinity,
      height: size.height,
      child: Stack(
        // alignment: Alignment.center,
        children: <Widget>[
          Positioned(
              top: getPortraitSHeight(33),
              left: getPortraitSWidth(10),
              child: InkWell(
                onTap: tapPress,
                child: Image.asset(
                  "assets/images/icon_back_black.png",
                  width: getPortraitSWidth(10.5),
                  height: getPortraitSHeight(18),
                  // width: size.width * 0.35,
                ),
              )),
          Positioned(
            bottom: 10,
            right: 0,
            left: 0,
            child: Container(
              alignment: Alignment.bottomCenter,
              child: Text.rich(TextSpan(children: [
                TextSpan(
                  text: "登录代表你已阅读并同意",
                  style:
                      TextStyle(fontSize: setSp(11), color: Color(0xFFcbcbcb)),
                ),
                TextSpan(
                    text: "《用户协议》",
                    style: TextStyle(
                        fontSize: setSp(11), color: Color(0xFFf00c22)),
                    recognizer: _tapGestureRecognizer),
                TextSpan(
                    text: "《隐私协议》",
                    style: TextStyle(
                        fontSize: setSp(11), color: Color(0xFFf00c22)),
                    recognizer: _tapGestureRecognizerPri),
              ])),
            ),
            // child: Image.asset(
            //   "assets/images/login_bottom.png",
            //   width: size.width * 0.4,
            // ),
          ),
          Positioned(
            top: getPortraitSWidth(163.5),
            left: getPortraitSWidth(1),
            child: child,
          )
        ],
      ),
    );
  }
}
